<?php

namespace app\index\observer;

use app\index\model\Reply as ReplyModel;

class Reply
{
    public function afterInsert(ReplyModel $reply)
    {
        $topic = $reply->topic;
        if(!empty($topic)){
            $topic->reply_count = $topic->replies->count();
            $topic->save();
        }
    }
}
